package com.example.neusoft.yuejian.Activity;

import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.neusoft.yuejian.Base.BaseActivity;

import com.example.neusoft.yuejian.Base.BaseListener;
import com.example.neusoft.yuejian.Base.BaseModel;
import com.example.neusoft.yuejian.Bean.Enrollbean;
import com.example.neusoft.yuejian.Bean.exercisesbean;
import com.example.neusoft.yuejian.R;

import retrofit2.Call;

public class ExernrollActivity extends BaseActivity implements View.OnClickListener {
    private exercisesbean exer;
    private TextView tx_norden,tx_nordej,tx_nortime,tx_nordesp,tx_noru,tx_noruname,tx_nornum,tx_money;
    private Button btn_bao;
    private int id;
    @Override
    public int getLayoutFile() {
        return R.layout.activity_exerenroll;
    }

    @Override
    public void initView() {
        tx_norden=findViewById(R.id.tx_norden);
        tx_nordej=findViewById(R.id.tx_nordej);
        tx_nortime=findViewById(R.id.tx_nortime);
        tx_nordesp=findViewById(R.id.tx_nordesp);
        tx_noru=findViewById(R.id.tx_noru);
        tx_noruname=findViewById(R.id.tx_noruname);
        tx_nornum=findViewById(R.id.tx_nornum);
        tx_money=findViewById(R.id.tx_money);
        btn_bao=findViewById(R.id.btn_bao);
    }

    @Override
    public void initEvent() {
            btn_bao.setOnClickListener(this);
    }

    @Override
    public void initData() {
        exer=(exercisesbean)getIntent().getSerializableExtra("exer");
        tx_norden.setText(exer.getExername());
        tx_nordej.setText(exer.getExerintro());
        tx_nordesp.setText(exer.getExeraddress());
        tx_nortime.setText(exer.getExerstarttime());
        id=exer.getExerid();


    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.btn_bao:
                getnor(4,id);
                break;
        }
    }
    public void getnor(int id,int uid){
        BaseModel<Enrollbean> model=new BaseModel<>();
        Call<Enrollbean> call=model.service.getEnroll(id,uid);
        model.callEnqueue(call,listener);
    }
    BaseListener<Enrollbean> listener=new BaseListener<Enrollbean>() {
        @Override
        public void onResponse(Enrollbean enrollbean) {
            if(enrollbean.getStatus()==1){
                showToast(enrollbean.getMessage());

            }else{
                showToast(enrollbean.getMessage());

            }
        }

        @Override
        public void onFail(String message) {
            showToast("123");
        }
    };
}
